Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var e = getApp(), n = {
    checkSessionKey: function() {
        return new Promise(function(e, n) {
            wx.checkSession({
                success: function() {
                    e();
                },
                fail: function() {
                    n();
                }
            });
        });
    },
    wxLogin: function() {
        return new Promise(function(n, o) {
            wx.login({
                success: function(o) {
                    Date.now() - (e.globalData.loginCodeRequestTime || -1) >= 1e3 && (e.globalData.loginCode = o.code, 
                    e.globalData.loginCodeRequestTime = Date.now()), e.globalData.loginCode = o.code, 
                    n(o.code);
                },
                fail: function() {
                    o("wx.login失败");
                }
            });
        });
    },
    wxAuthorize: function(e) {
        var n = e.scope;
        return new Promise(function(e, o) {
            wx.getSetting({
                scope: n,
                success: function(n) {
                    return e(n);
                },
                fail: function() {
                    return o("wx.getSetting失败");
                }
            });
        });
    },
    wxPay: function(e) {
        var n = e.appId, o = void 0 === n ? "wxc47d9eb33eec8b6a" : n, t = e.timeStamp, i = void 0 === t ? String(Date.now() / 1e3) : t, c = e.nonceStr, a = e.pkg, s = e.signType, r = e.paySign, u = e.appid, l = e.path;
        return new Promise(function(e, n) {
            console.log("======小程序调起微信支付的参数====="), console.log({
                appId: o,
                timeStamp: i,
                nonceStr: c,
                package: a,
                signType: s,
                paySign: r
            }), wx.requestPayment({
                appId: o,
                timeStamp: i,
                nonceStr: c,
                package: a,
                signType: s,
                paySign: r,
                success: function(o) {
                    console.log(o), -1 !== o.errMsg.indexOf("ok") ? e({
                        appid: u,
                        path: l
                    }) : -1 !== o.errMsg.indexOf("cancel") && n("cancel");
                },
                fail: function(e) {
                    console.log(e), -1 !== e.errMsg.indexOf("cancel") ? n("cancel") : n("fail");
                },
                complete: function(e) {
                    console.log(e);
                }
            });
        });
    },
    setClipboardData: function(e) {
        return new Promise(function(n, o) {
            wx.setClipboardData({
                data: e,
                success: function(e) {
                    n(e);
                },
                fail: function(e) {
                    o(e);
                }
            });
        });
    }
};

exports.default = n;